var iadvinittop=0;
var icloseinittop=0;
window.onload =function () {
    var oDt=new Date();
    var sWd="";
    var iWeedDay=oDt.getDay();
    switch (iWeedDay){
        case 0:
            sWd="星期日";break;
        case 1:
            sWd="星期一";break;
        case 2:
            sWd="星期二";break;
        case 3:
            sWd="星期三";break;
        case 4:
            sWd="星期四";break;
        case 5:
            sWd="星期五";break;
        case 6:
            sWd="星期六";break;
    }
    var iMonth=parseInt(oDt.getMonth())+1;
    document.getElementById("displaydate").innerHTML="<span>"+oDt.getFullYear()+"年"+iMonth+"月"+oDt.getDate()+"日"+sWd+"</span>";
    var iTimerid = window.setInterval("showtime()", 1000);

    if(document.getElementById("a1")!==null){
        document.getElementById("a1").onmouseover=function () {
            document.getElementById("badimg").src="../sourcebook/b-ad1.jpg";
        }
    }
    if(document.getElementById("a2")!==null){
        document.getElementById("a2").onmouseover=function () {
            document.getElementById("badimg").src="../sourcebook/b-ad2.jpg";
        }
    }
    if(document.getElementById("a3")!==null){
        document.getElementById("a3").onmouseover=function () {
            document.getElementById("badimg").src="../sourcebook/b-ad3.jpg";
        }
    }
    if(document.getElementById("a4")!==null){
        document.getElementById("a4").onmouseover=function () {
            document.getElementById("badimg").src="../sourcebook/b-ad4.jpg";
        }
    }
    window.onscroll=function () {
        advmove();
    };
    if(document.getElementById("adv1")!=null){advinit();}
    if(document.getElementById("close1")!=null){document.getElementById("close1").onclick=
        function () { close1() };}
    if(document.getElementById("closer")!=null){document.getElementById("closer").onclick=
        function () { closer() };}
};
function showtime() {
    var oDt=new Date()
    var iTimerid;
    var sTime="";
    if (oDt.getHours()<10){
        sTime+="0"+oDt.getHours()+":";
    }
    else {
        sTime+=oDt.getHours()+":";
    }
    if (oDt.getMinutes()<10){
        sTime+="0"+oDt.getMinutes()+":";
    }
    else {
        sTime+=oDt.getMinutes()+":";
    }
    if(oDt.getSeconds()<10){
        sTime+="0"+oDt.getSeconds();
    }
    else {
        sTime+=oDt.getSeconds();
    }
    document.getElementById("displaytime").innerHTML="<span>"+sTime+"</span>";
}
function advmove() {
    if(document.getElementById("adv1"!=null)){
        var ix ,iy;
        iy=document.body.scrollTop;
        ix=document.body.scrollLeft;
        if(browser.chorme){
            iy=document.body.scrollTop;
            ix=document.body.scrollLeft;
        }
        var top1=iadvinittop+iy;
        var top2=icloseinittop+ix;
        top1=top1.toString()+"px";
        top2=top2.toString()+"px";
        document.getElementById("adv1").style.top=top1;
        document.getElementById("close1").style.top=top2;
        document.getElementById("advr").style.top=top1;
        document.getElementById("closer").style.top=top2;
    }
}
function advinit() {
    var otop=document.getElementById("advaddr").offsetTop+"px";
    var oleft=document.getElementById("advaddr").offsetLeft-
        document.getElementById("adv1").offsetWidth;
    oleft=oleft.toString()+"px";
    document.getElementById("adv1").style.top=otop;
    document.getElementById("adv1").style.left=oleft;
    var otop=document.getElementById("advaddr").offsetTop+
        document.getElementById("adv1").offsetHeight-document.getElementById("close1").offsetHeight+"px";
    var oleft=document.getElementById("advaddr").offsetLeft-document.getElementById("close1").offsetWidth;
    oleft=oleft.toString()+"px";
    document.getElementById("close1").style.top=otop;
    document.getElementById("close1").style.left=oleft;
    iadvinittop=document.getElementById("adv1").offsetTop=otop;
    icloseinittop=document.getElementById("close1").offsetTop=oleft;
    var otop=document.getElementById("advaddr").offsetTop+"px";
    var oleft=document.getElementById("advaddr").offsetLeft+
        document.getElementById("advaddr").offsetWidth;
    oleft=oleft.toString()+"px";
    document.getElementById("advr").style.top=otop;
    document.getElementById("advr").style.left=oleft;
    var otop=document.getElementById("advaddr").offsetTop+
        document.getElementById("advr").offsetHeight-document.getElementById("closer").offsetHeight+"px";
    var oleft=document.getElementById("advaddr").offsetLeft+document.getElementById("advaddr").offsetWidth+
        document.getElementById("advr").offsetWidth-document.getElementById("closer").offsetWidth;
    oleft=oleft.toString()+"px";
    document.getElementById("closer").style.top=otop;
    document.getElementById("closer").style.left=oleft;
}
function close1() {
    document.getElementById("adv1").style.display="none";
    document.getElementById("close1").style.display="none";
}
function closer() {
    document.getElementById("advr").style.display="none";
    document.getElementById("closer").style.display="none";
}

